package com.example.takeaway.converter;

import com.example.takeaway.model.bo.Order;
import com.example.takeaway.model.bo.OrderItem;
import com.example.takeaway.model.dto.OrderSubmitDTO;
import com.example.takeaway.model.vo.CartItemVO;
import com.example.takeaway.model.vo.OrderItemVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * @author 邢晨旭
 * {@code @date} 2023/10/22
 */
@Mapper(componentModel = "spring")
public interface OrderConverter {
    @Mapping(target = "amount", source = "price")
    @Mapping(target = "id", source = "id", ignore = true)
    OrderItemVO toOrderReview(CartItemVO vo);

    List<OrderItemVO> toOrderReview(List<CartItemVO> vos);


    Order toOrder(OrderSubmitDTO orderSubmit);

    @Mapping(target = "amount", source = "price")
    @Mapping(target = "id", source = "id", ignore = true)
    OrderItem toOrderItem(CartItemVO vo);

    List<OrderItem> toOrderItem(List<CartItemVO> vos);
}
